package cn.cvs.service.supplier;

import cn.cvs.dao.StorageRecordMapper;
//import cn.cvs.dao.SupplierMapper;
import cn.cvs.entity.Supplier;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
	@Override
	public List<Supplier> getList(String supName, String supCode, int currentPageNo, int pageSize) throws Exception {
		return null;
	}

	@Override
	public int getCount(String supName, String supCode) throws Exception {
		return 0;
	}

	@Override
	public List<Supplier> getList() throws Exception {
		return null;
	}
//	@Resource
//	private SupplierMapper supplierMapper;
//	@Resource
//	private StorageRecordMapper storageRecordMapper;
//
//	@Override
//	public List<Supplier> getList(String supName, String supCode
//			, int pageIndex, int pageSize) throws Exception {
//		int pageBegin = (pageIndex-1)*pageSize;
//		return supplierMapper.selectList(supName, supCode, pageBegin, pageSize);
//	}
//	@Override
//	public int getCount(String supName, String supCode) throws Exception {
//		return supplierMapper.selectCount(supName, supCode);
//	}
//
//	@Override
//	public List<Supplier> getList() throws Exception {
//		return null;
//	}

/**
	 * 保存供货商信息
	 */

//	@Override
//	public boolean add(Supplier supplier) throws Exception {
//		boolean flag = false;
//		supplier.setCreatedTime(new Date());
//		if(supplierMapper.add(supplier) > 0)
//			flag = true;
//		return flag;
//	}

//	@Override
//	public List<Supplier> getList() throws Exception {
//		return supplierMapper.selectSimpleList();
//	}

//	@Override
//	public Supplier getById(Integer id) throws Exception {
//		return  supplierMapper.selectById(id);
//	}



/**
	 * 修改供货商信息
	 *//*

	@Override
	public boolean update(Supplier supplier) throws Exception {
		boolean flag = false;
		supplier.setUpdatedTime(new Date());
		if(supplierMapper.update(supplier) > 0)
			flag = true;
		return flag;
	}

	@Override
	public boolean deleteById(Integer id) throws Exception {
		boolean flag = true;
		int billCount = storageRecordMapper.selectCountBySupplierId(id);
		if(billCount > 0 ){//先订单信息
			storageRecordMapper.deleteBySupplierId(id);
		}
		//先删除该条记录的上传文件
		Supplier supplier = supplierMapper.selectById(id);
		if(supplier.getCompanyLicPicPath() != null && !supplier.getCompanyLicPicPath().equals("")){
			//删除服务器上企业营业执照照片
			File file = new File(supplier.getCompanyLicPicPath());
			if(file.exists()){
				flag = file.delete();
			}
		}
		if(flag && supplier.getOrgCodePicPath() != null && !supplier.getOrgCodePicPath().equals("")){
			//删除服务器上组织机构代码证照片
			File file = new File(supplier.getOrgCodePicPath());
			if(file.exists()){
				flag = file.delete();
			}
		}
		if(!flag){
			throw new Exception();
		}
		supplierMapper.deleteById(id);
		return flag;
	}*/
}

